package edu.ccut.saturn.studio.logic.model.saturn.action;

import org.eclipse.draw2d.geometry.Point;

import edu.ccut.saturn.studio.action.ActionMultiPageEditor;
import edu.ccut.saturn.studio.logic.model.Shape;
import edu.ccut.saturn.studio.logic.model.ShapesDiagram;
import edu.ccut.saturn.studio.logic.model.saturn.SaturnStartNode;
import edu.ccut.saturn.studio.logic.model.saturn.logic.SaturnStartNodeInLogic;

public class SaturnStartNodeInAction extends SaturnStartNode {

	private static final long serialVersionUID = 1L;

	@Override
	public Shape cloneShape(Point mousePoint, Shape shape) {
		ShapesDiagram diagram = (ShapesDiagram)shape.getParent();
		if(diagram.getEditors() instanceof ActionMultiPageEditor) {
			SaturnStartNodeInAction saturnStartNode = new SaturnStartNodeInAction();
			SaturnStartNodeInAction saturn = (SaturnStartNodeInAction)shape;
			saturnStartNode.setLocation(mousePoint);
			saturnStartNode.setName(saturn.getName());
			saturnStartNode.setAutorollback(saturn.getAutorollback());
			saturnStartNode.setDescription(saturn.getDescription());
			saturnStartNode.setParameters(saturn.getParameters());
			saturnStartNode.setId(saturn.getId());
			saturnStartNode.setNextId(saturn.getNextId());
			return saturnStartNode;
		}else{
			SaturnStartNodeInLogic saturnStartNode = new SaturnStartNodeInLogic();
			SaturnStartNodeInAction saturn = (SaturnStartNodeInAction)shape;
			saturnStartNode.setLocation(mousePoint);
			saturnStartNode.setName(saturn.getName());
			saturnStartNode.setAutorollback(saturn.getAutorollback());
			saturnStartNode.setDescription(saturn.getDescription());
			saturnStartNode.setParameters(saturn.getParameters());
			saturnStartNode.setId(saturn.getId());
			saturnStartNode.setNextId(saturn.getNextId());
			return saturnStartNode;
		}
	}
}
